﻿//Created by Action Script Viewer - http://www.buraks.com/asv
package reprise.css {
    import reprise.css.*;

    class CSSDeclarationListItem {

        public var declarationSpecificity:int;
        protected var m_declaration:CSSDeclaration;
        protected var m_selector:String;
        public var declarationIndex:int;
        protected var m_selectorPattern:Array;

        function CSSDeclarationListItem(_arg1:String, _arg2:CSSDeclaration, _arg3:int, _arg4:String=null){
            m_selector = _arg1;
            var _local5:String = (("@" + _arg1.split(" ").join("@ @").split("#").join("|#").split(":").join("|:").split(".").join("|.")).split("||").join("|").split("|").join("@|@").split(">@").join("@>").split(">").join("|>") + "@").split("@@").join("@").split(" @|@").join(" @");
            if (_local5.substr(0, 3) == "@|@"){
                _local5 = _local5.substr(2);
            };
            m_selectorPattern = _local5.split(" ");
            var _local6:int = m_selectorPattern.length;
            while (_local6--) {
                m_selectorPattern[_local6] = m_selectorPattern[_local6].split("|");
                if (".:#".indexOf(m_selectorPattern[_local6][0].charAt(1)) == -1){
                    m_selectorPattern[_local6][0] = m_selectorPattern[_local6][0].toLowerCase();
                };
            };
            declarationSpecificity = specificityForSelector(_arg1);
            declarationIndex = _arg3;
            m_declaration = CSSDeclaration(_arg2);
        }
        protected function specificityForPattern(_arg1:String):int{
            var _local2 = 1;
            var _local3 = 10;
            var _local4 = 100;
            var _local5:int;
            var _local6:Array = _arg1.split(":").join(".:").split(".");
            _local5 = (_local5 + ((_local6.length - 1) * _local3));
            _local6 = _local6[0].split("#");
            if (_local6[0] != ""){
                _local5 = (_local5 + _local2);
            };
            if (_local6[1]){
                _local5 = (_local5 + _local4);
            };
            return (_local5);
        }
        function matchesSubjectPath(_arg1:String):Boolean{
            var _local6:Array;
            var _local7:int;
            var _local8:String;
            var _local9:Array;
            var _local10:int;
            var _local11:int;
            var _local12:String;
            var _local13:int;
            var _local2:int = _arg1.length;
            var _local3:int = (_arg1.lastIndexOf(" ") + 1);
            var _local4 = 1;
            _arg1 = (_arg1 + " ");
            var _local5:int = m_selectorPattern.length;
            while (_local5--) {
                _local6 = m_selectorPattern[_local5];
                _local8 = m_selectorPattern[_local5][(_local6.length - _local4)];
                _local4 = 1;
                if ((((_local8 == "@*@")) && ((_local6.length == 1)))){
                    _local7 = _arg1.lastIndexOf(" ", (_local2 - 1));
                } else {
                    _local10 = _arg1.lastIndexOf(_local8, _local2);
                    if (_local10 < _local3){
                        return (false);
                    };
                    _local7 = _arg1.lastIndexOf(" ", _local10);
                    _local11 = _arg1.indexOf(" ", _local10);
                    _local12 = _arg1.substring((_local7 + 1), _local11);
                    _local13 = (_local6.length - 1);
                    while (_local13--) {
                        _local8 = _local6[_local13];
                        if (_local12.indexOf(_local8) == -1){
                            return (false);
                        };
                    };
                };
                _local9 = m_selectorPattern[(_local5 - 1)];
                if (((_local9) && ((_local9[(_local9.length - 1)] == ">")))){
                    _local3 = (_arg1.lastIndexOf(" ", (_local7 - 1)) + 1);
                    _local4 = 2;
                } else {
                    _local3 = 0;
                };
                _local2 = _local7;
            };
            return (true);
        }
        public function toString():String{
            return ((m_selector + declarationIndex));
        }
        function declaration():CSSDeclaration{
            return (m_declaration);
        }
        protected function specificityForSelector(_arg1:String):int{
            var _local2:Array = _arg1.split(" ");
            var _local3:int;
            var _local4:int = _local2.length;
            while (_local4--) {
                _local3 = (_local3 + specificityForPattern(_local2[_local4]));
            };
            return (_local3);
        }

    }
}//package reprise.css 
